/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package org.icad.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Gabriel Bran gbran.u@gmail.com
 */
@Entity
@Table(name = "detalle_transaccion")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "DetalleTransaccion.findAll", query = "SELECT d FROM DetalleTransaccion d"),
    @NamedQuery(name = "DetalleTransaccion.findByIglesia", query = "SELECT d FROM DetalleTransaccion d WHERE d.detalleTransaccionPK.iglesia = :iglesia"),
    @NamedQuery(name = "DetalleTransaccion.findByFecha", query = "SELECT d FROM DetalleTransaccion d WHERE d.detalleTransaccionPK.fecha = :fecha"),
    @NamedQuery(name = "DetalleTransaccion.findByCorrelativo", query = "SELECT d FROM DetalleTransaccion d WHERE d.detalleTransaccionPK.correlativo = :correlativo"),
    @NamedQuery(name = "DetalleTransaccion.findByCuenta", query = "SELECT d FROM DetalleTransaccion d WHERE d.detalleTransaccionPK.cuenta = :cuenta"),
    @NamedQuery(name = "DetalleTransaccion.findByCargo", query = "SELECT d FROM DetalleTransaccion d WHERE d.cargo = :cargo"),
    @NamedQuery(name = "DetalleTransaccion.findByAbono", query = "SELECT d FROM DetalleTransaccion d WHERE d.abono = :abono"),
    @NamedQuery(name = "DetalleTransaccion.findByNumeroDocto", query = "SELECT d FROM DetalleTransaccion d WHERE d.numeroDocto = :numeroDocto")})
public class DetalleTransaccion implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected DetalleTransaccionPK detalleTransaccionPK;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "cargo")
    private Double cargo;
    @Column(name = "abono")
    private Double abono;
    @Size(max = 25)
    @Column(name = "numero_docto")
    private String numeroDocto;
    @JoinColumn(name = "miembro", referencedColumnName = "id")
    @ManyToOne
    private Miembro miembro;
    @JoinColumns({
        @JoinColumn(name = "iglesia", referencedColumnName = "iglesia", insertable = false, updatable = false),
        @JoinColumn(name = "fecha", referencedColumnName = "fecha", insertable = false, updatable = false),
        @JoinColumn(name = "correlativo", referencedColumnName = "correlativo", insertable = false, updatable = false)})
    @ManyToOne(optional = false)
    private TransaccionContable transaccionContable;
    @JoinColumns({
        @JoinColumn(name = "iglesia", referencedColumnName = "iglesia", insertable = false, updatable = false),
        @JoinColumn(name = "cuenta", referencedColumnName = "codigo", insertable = false, updatable = false)})
    @ManyToOne(optional = false)
    private CatalogoContable catalogoContable;
    @JoinColumns({
        @JoinColumn(name = "iglesia", referencedColumnName = "iglesia", insertable = false, updatable = false),
        @JoinColumn(name = "tipo_docto", referencedColumnName = "codigo")})
    @ManyToOne(optional = false)
    private TipoDocumento tipoDocumento;

    public DetalleTransaccion() {
    }

    public DetalleTransaccion(DetalleTransaccionPK detalleTransaccionPK) {
        this.detalleTransaccionPK = detalleTransaccionPK;
    }

    public DetalleTransaccion(int iglesia, Date fecha, int correlativo, int cuenta) {
        this.detalleTransaccionPK = new DetalleTransaccionPK(iglesia, fecha, correlativo, cuenta);
    }

    public DetalleTransaccionPK getDetalleTransaccionPK() {
        return detalleTransaccionPK;
    }

    public void setDetalleTransaccionPK(DetalleTransaccionPK detalleTransaccionPK) {
        this.detalleTransaccionPK = detalleTransaccionPK;
    }

    public Double getCargo() {
        return cargo;
    }

    public void setCargo(Double cargo) {
        this.cargo = cargo;
    }

    public Double getAbono() {
        return abono;
    }

    public void setAbono(Double abono) {
        this.abono = abono;
    }

    public String getNumeroDocto() {
        return numeroDocto;
    }

    public void setNumeroDocto(String numeroDocto) {
        this.numeroDocto = numeroDocto;
    }

    public Miembro getMiembro() {
        return miembro;
    }

    public void setMiembro(Miembro miembro) {
        this.miembro = miembro;
    }

    public TransaccionContable getTransaccionContable() {
        return transaccionContable;
    }

    public void setTransaccionContable(TransaccionContable transaccionContable) {
        this.transaccionContable = transaccionContable;
    }

    public CatalogoContable getCatalogoContable() {
        return catalogoContable;
    }

    public void setCatalogoContable(CatalogoContable catalogoContable) {
        this.catalogoContable = catalogoContable;
    }

    public TipoDocumento getTipoDocumento() {
        return tipoDocumento;
    }

    public void setTipoDocumento(TipoDocumento tipoDocumento) {
        this.tipoDocumento = tipoDocumento;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (detalleTransaccionPK != null ? detalleTransaccionPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof DetalleTransaccion)) {
            return false;
        }
        DetalleTransaccion other = (DetalleTransaccion) object;
        if ((this.detalleTransaccionPK == null && other.detalleTransaccionPK != null) || (this.detalleTransaccionPK != null && !this.detalleTransaccionPK.equals(other.detalleTransaccionPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.icad.entity.DetalleTransaccion[ detalleTransaccionPK=" + detalleTransaccionPK + " ]";
    }
    
}
